package com.reyco1.medusa.display.control
{
	import com.reyco1.medusa.display.SmartSprite;
	import com.reyco1.medusa.display.graphics.Box;
	import com.reyco1.medusa.util.AlignUtil;

	public class SpinnerOverlay extends BaseControl
	{
		private var spinner:Spinner;
		private var label:Label;
		private var background:SmartSprite;
		
		private var _opacity:Number;
		private var _text:String;
		
		public function SpinnerOverlay(strlabel:String = "", w:Number = 100, h:Number = 100, backgroundOpacity:Number = .35)
		{
			super();
			_text	 = strlabel;
			_width   = w;
			_height  = h;
			_opacity = backgroundOpacity;
			
			build();
		}
		
		/* private */
		
		override protected function build():void
		{
			removeAllChildren();			
			
			background = Box.draw(0, 0, _width, _height, 0x000000, _opacity);
			addChild(background);
			
			spinner = new Spinner(12, 4, 0xFFFFFF);
			addChild(spinner);
			
			label = new Label(_text, "Arial", 12, 0xFFFFFF, false, true);
			addChild(label);
			
			AlignUtil.middleCenter(this, spinner);
			
			if(label.text != "")
			{
				spinner.y += 5;
				label.x = _width * 0.5 - label.width * 0.5;
				label.y = spinner.y - spinner.height;
			}
		}
		
		/* properties */

		public function get text():String
		{
			return _text;
		}

		public function set text(value:String):void
		{
			_text = value;
		}

		public function get opacity():Number
		{
			return _opacity;
		}

		public function set opacity(value:Number):void
		{
			_opacity = value;
		}


	}
}